//
//  WHExpressOperationView.m
//  SquirrelSeller
//
//  Created by 邓伟浩 on 2019/1/2.
//  Copyright © 2019 邓伟浩. All rights reserved.
//

#import "WHExpressOperationView.h"

@interface WHExpressOperationView ()

@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) UIImageView *tipsImageView;
@property (nonatomic, strong) UILabel *tipsLabel;

@end

@implementation WHExpressOperationView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setUpOperationView];
    }
    return self;
}

- (void)setUpOperationView {
    [self addSubview:({
        _backView = [[UIView alloc] init];
        
//        _backView.layer.cornerRadius  = 12;
//        _backView.layer.masksToBounds = NO;
//
//        _backView.layer.shadowColor = HexColor(@"002233").CGColor;
//        _backView.layer.shadowOffset = CGSizeMake(0, 0);
//        _backView.layer.shadowOpacity = 0.1;
//        _backView.layer.shadowRadius = 5;
//
//        _backView.backgroundColor = KWhiteColor;
        
        _backView;
    })];
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self);
    }];
    
    [self addSubview:({
        _tipsImageView = [[UIImageView alloc] init];
        _tipsImageView.contentMode = UIViewContentModeScaleAspectFit;
        _tipsImageView;
    })];
    
    [_tipsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(kRealwidth(55));
        make.centerX.mas_equalTo(_backView.mas_centerX);
        make.top.mas_equalTo(_backView.mas_top).offset(kRealwidth(38));
    }];
    
    [self addSubview:({
        _tipsLabel = [[UILabel alloc] init];
        _tipsLabel.textColor = CFontTitleBlackColor;
        _tipsLabel.textAlignment = NSTextAlignmentCenter;
        _tipsLabel.font = SYSTEMFONT(kRealwidth(16));
        _tipsLabel;
    })];
    
    [_tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_backView.mas_centerX);
        make.top.mas_equalTo(_tipsImageView.mas_bottom).offset(kRealwidth(20));
        make.height.mas_equalTo(kRealwidth(16));
    }];
    
    UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClicked)];
    [self addGestureRecognizer:tapGes];
}

- (void)setTipsImage:(UIImage *)tipsImage {
    _tipsImage = tipsImage;
    _tipsImageView.image = tipsImage;
}

- (void)setTipsText:(NSString *)tipsText {
    _tipsText = tipsText;
    _tipsLabel.text = tipsText;
}

- (void)tapClicked {
    if (self.opreation) {
        self.opreation();
    }
}

@end
